package homework;

import java.util.Scanner;

public class homework1 {
    public static void main(String[] args) {
        //判断年龄
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年龄：");
        int a = sc.nextInt();
        if(a<0){
            System.out.println("输入年龄不合理！");
        } else if (a<=18) {
            System.out.println("少年");
        } else if (a<=28) {
            System.out.println("青年");
        } else if (a<=55) {
            System.out.println("中年");
        }else {
            System.out.println("老年");
        }
    }
    public static void main4(String[] args) {
        //判断一个数是否为素数
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        int a = sc.nextInt();
        int i = 2;
        for (; i <=a/2; i++) {
            if(a%i==0){
                System.out.println(a+"不是素数");
                break;
            }
        }
        if(i>a/2){
            System.out.println(a+"是素数");
        }
    }
    public static void main3(String[] args) {
        //打印1-100之间所有的素数
        for (int i = 2; i <=100 ; i++) {
            int j = 2;
            for (; j <=i/2 ; j++) {
                if(i%j==0){
                    break;
                }
            }
            if(j>i/2){
                System.out.println(i);
            }
        }
    }
    public static void main2(String[] args) {
        //输出1000-2000年之间的闰年，并以每行20个数输出
        int count = 0;
        for (int i = 1000; i <=2000; i++) {
            if(i%100==0 && i%400==0){
                System.out.print(i+" ");
                count++;
                if(count%20==0){
                    System.out.println();
                }
            }else if(i%4==0) {
                System.out.print(i+" ");
                count++;
                if(count%20==0){
                    System.out.println();
                }
            }
        }
    }

    //统计1-100中数字9出现的次数
    public static void main1(String[] args) {
        int sum = 0;
        for (int i = 1; i <=100 ; i++) {
            if(i%10==9){
                sum++;
            }
            if(i/10==9){
                sum++;
            }
        }
        System.out.println(sum);
    }
}
